import { R } from '@/api/model/R';
import request from '@/utils/request';
import { Collect } from '../model/Collect';

/**
 * 获取收藏状态
 * @param dataId 业务Id
 * @param type 业务类型
 */
export function isCollect(dataId: number | string, type: string): Promise<R<boolean>> {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    return request({
        url: `/business/collect/status/${dataId}`,
        method: 'get',
        params: { type }
    });
}

/**
 * 收藏、取消收藏
 * @param dataId 业务Id
 * @param type 业务类型
 */
export function collect(dataId: number | string, type: string): Promise<R<boolean>> {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    return request({
        url: `/business/collect`,
        method: 'post',
        data: { type, dataId }
    });
}


/**
 * 获取我收藏的
 */
export function getMyCollect(query: any): Promise<R<Collect>> {
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    return request({
        url: `/business/collect/my`,
        method: 'get',
        params: query
    });
}
